package edu.ilstu.mind.ise.module.arduino.controller;

public interface ArduinoController {

	/**
	 * Check that communication can occur with the board
	 * 
	 * @return if ping was successful
	 */
	boolean ping();

	/**
	 * Get the version string reported by the Arduino Board
	 * 
	 * @return The version string
	 * @throws ArduinoException
	 *             When the board does not recognize the version command
	 */
	String getVersion() throws ArduinoException;
	
	/**
	 * Set the pin mode for a particular pin
	 * 
	 * @param pinId
	 *            The pin id
	 * @param pinMode
	 *            The pin mode to set
	 * @throws ArduinoException
	 *             When the pin does not exist on the board or the pin does not
	 *             support the pinType
	 */
	void setPinMode(String pinId, PinMode pinMode) throws ArduinoException;

	/**
	 * Write a boolean to a DIGITAL_OUTPUT pin
	 * 
	 * @param pinId
	 *            The pin id
	 * @param value
	 *            The value to set
	 * @throws ArduinoException
	 *             When the pin does not exist or the pin is not of the given
	 *             pin type
	 */
	void digitalWrite(String pinId, boolean value) throws ArduinoException;

	/**
	 * Write a value [0-255] to a ANALOG_OUTPUT pin
	 * 
	 * @param pinId
	 *            The pin id
	 * @param value
	 *            The value to set
	 * @throws ArduinoException
	 *             When the pin does not exist or the pin is not of the given
	 *             pin type
	 */
	void analogWrite(String pinId, int value) throws ArduinoException;

	/**
	 * Read a digital value from a DIGITAL_INPUT pin
	 * 
	 * @param pinId
	 *            The pin id
	 * @return The boolean value of the pin
	 * @throws ArduinoException
	 *             When the pin does not exist or the pin is not of the given
	 *             pin type
	 */
	boolean digitalRead(String pinId) throws ArduinoException;

	/**
	 * Read an analog value from an ANALOG_INPUT pin
	 * 
	 * @param pinId
	 *            The pin id
	 * @return The value [0-1023] of the pin
	 * @throws ArduinoException
	 *             When the pin does not exist or the pin is not of the given
	 *             pin type
	 */
	int analogRead(String pinId) throws ArduinoException;
}
